package com.nova.android.tvlauncher.ui.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.leanback.widget.HorizontalGridView
import androidx.recyclerview.widget.RecyclerView
import com.nova.android.tvlauncher.R

class CustomAdapter(private val data: List<String>) :
    RecyclerView.Adapter<CustomAdapter.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        // 创建视图并返回 ViewHolder
        val view =
            LayoutInflater.from(parent.context).inflate(R.layout.item_home_parent, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        // 绑定数据到视图
        val item = data[position]
        holder.textView.text = item
        holder.rvContent.adapter = CustomAdapter1(listOf("1","","","","","","","","","","","","","","","","","","",""))
    }

    override fun getItemCount(): Int {
        return data.size
    }

    class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var textView: TextView = itemView.findViewById(R.id.tv_title)
        var rvContent: HorizontalGridView =
            itemView.findViewById(R.id.rv_content)
    }
}
